import { MockMethod } from 'vite-plugin-mock'
import mockjs from 'mockjs'

mockjs.Random.extend({
  phone: function () {
    return this.pick(['132', '135', '189']) + mockjs.mock(/\d{8}/)
  }
})

export default <MockMethod[]>[
  {
    url: '/login',
    method: 'get',
    response: () => {
      return {
        code: 200,
        data: mockjs.mock({
          'number1|1-100.1-10': 1
        })
      }
    }
  },
  {
    url: '/list',
    method: 'get',
    timeout: 400,
    response: () => {
      return mockjs.mock({
        code: 200,
        'rows|10': [
          {
            'id|1': () => mockjs.Random.guid(),
            'xm|1': () => mockjs.Random.cname(),
            'gender|1': [0, 1],
            'phone|1-10': () => mockjs.Random.phone(),
            'sfhm|1': () => mockjs.Random.id(),
            'zz|1': () => mockjs.Random.county(true),
            'auditStatus|1': [-1, 0, 1]
          }
        ],
        total: 20,
        msg: '查询成功'
      })
    }
  },
  {
    url: '/detail',
    method: 'get',
    timeout: 400,
    response: () => {
      return mockjs.mock({
        code: 200,
        data: {
          'id|1': () => mockjs.Random.guid(),
          'xm|1': () => mockjs.Random.cname(),
          'gender|1': [0, 1],
          'phone|1-10': () => mockjs.Random.phone(),
          'sfhm|1': () => mockjs.Random.id(),
          'zz|1': () => mockjs.Random.county(true),
          'auditStatus|1': [-1, 0, 1]
        },
        msg: '查询成功'
      })
    }
  },
  {
    url: '/audit',
    method: 'get',
    timeout: 200,
    response: () => {
      return {
        code: 200,
        msg: '操作成功'
      }
    }
  },
  {
    url: '/add',
    method: 'get',
    timeout: 200,
    response: () => {
      return {
        code: 200,
        msg: '操作成功'
      }
    }
  }
]
